<?php

require_once dirname(__FILE__) . '/../../Extension/Params.php';
require_once dirname(__FILE__) . '/TextValues.php';


class Rams_Extension_StorageParams extends Raws_Extension_Params
{
  
  // protected $_rootNamespace = 'raws';
  // protected $_rootElement = 'params';

    # child elements of the params element
    protected $_volume = null;
    protected $_location = null;
    protected $_updated = null;

    public function __construct($path = null, $volume = null, $location = null, $updated = null) 
    {
        parent::__construct();
        $this->setVolume($volume);
        $this->setLocation($location);
        $this->setUpdated($updated);
    }
    
    /**
     * Retrieves a DOMElement which corresponds to this element and all
     * child properties.  This is used to build an entry back into a DOM
     * and eventually XML text for application storage/persistence.
     *
     * @param DOMDocument $doc The DOMDocument used to construct DOMElements
     * @return DOMElement The DOMElement representing this element and all
     *          child properties.
     */
    public function getDOM($doc = null)
    {
        $element = parent::getDOM($doc);
        if ($this->_volume !== null) {
            $element->appendChild($this->_volume->getDOM($element->ownerDocument));
        }
        if ($this->_location !== null) {
            $element->appendChild($this->_location->getDOM($element->ownerDocument));
        }
        if ($this->_updated !== null) {
            $element->appendChild($this->_updated->getDOM($element->ownerDocument));
        }
        return $element;
    }

    /**
     * Creates individual Entry objects of the appropriate type and
     * stores them as members of this entry based upon DOM data.
     *
     * @param DOMNode $child The DOMNode to process
     */
    protected function takeChildFromDOM($child)
    {
        $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
        
        switch ($absoluteNodeName) {
            case $this->lookupNamespace('raws') . ':' . 'volume'; 
                $volume = new Rams_Extension_Volume();
                $volume->transferFromDOM($child);
                $this->_volume = $volume;
                break;
            case $this->lookupNamespace('raws') . ':' . 'location'; 
                $location = new Rams_Extension_Location();
                $location->transferFromDOM($child);
                $this->_location = $location;
                break;
            case $this->lookupNamespace('raws') . ':' . 'updated'; 
                $updated = new Rams_Extension_Updated();
                $updated->transferFromDOM($child);
                $this->_updated = $updated;
                break;
            default:
                parent::takeChildFromDOM($child);
                break;
        }
    }
    
    public function getVolume()
    {
        return $this->_volume;
    }

    public function setVolume($value)
    {
        $this->_volume = $value;
        return $this;
    }

    public function getLocation()
    {
        return $this->_location;
    }

    public function setLocation($value)
    {
        $this->_location = $value;
        return $this;
    }

    public function getUpdated()
    {
        return $this->_updated;
    }

    public function setUpdated($value)
    {
        $this->_updated = $value;
        return $this;
    }

}
